package com.ss.android.article.base.ui;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.AnimationSet;
import android.view.animation.OvershootInterpolator;
import android.view.animation.ScaleAnimation;
import android.widget.ImageView;

public class AnimationImageView extends ImageView {
    AnimationSet a;
    public int b;
    public int c;
    boolean d;
    private AlphaAnimation e;
    private AlphaAnimation f;
    private ScaleAnimation g;
    private ScaleAnimation h;
    private OvershootInterpolator i;
    private AnimationSet j;
    private int k;
    private int l;
    private int m;
    private int n;
    private boolean o;
    private boolean p;

    public AnimationImageView(Context arg2) {
        this(arg2, null);
    }

    public AnimationImageView(Context arg2, AttributeSet arg3) {
        this(arg2, arg3, 0);
    }

    public AnimationImageView(Context arg10, AttributeSet arg11, int arg12) {
        super(arg10, arg11, arg12);
        this.e = new AlphaAnimation(1f, 0f);
        this.f = new AlphaAnimation(0f, 1f);
        this.g = new ScaleAnimation(0.6f, 1f, 0.6f, 1f, 1, 0.5f, 1, 0.5f);
        this.h = new ScaleAnimation(1f, 0.6f, 1f, 0.6f, 1, 0.5f, 1, 0.5f);
        this.i = new OvershootInterpolator(2f);
        this.j = new AnimationSet(false);
        this.a = new AnimationSet(false);
        this.o = false;
        this.d = false;
        this.p = false;
        if(arg11 != null) {
            TypedArray v0 = arg10.obtainStyledAttributes(arg11, com.ss.android.article.base.a.a, arg12, 0);
            this.k = v0.getResourceId(com.ss.android.article.base.a.b, 0);
            this.l = v0.getResourceId(com.ss.android.article.base.a.c, 0);
            this.adaptNightMode(this.p);
            v0.recycle();
        }

        this.e.setDuration(100);
        this.f.setDuration(200);
        this.h.setDuration(100);
        this.h.setInterpolator(this.i);
        this.g.setDuration(200);
        this.g.setInterpolator(this.i);
        this.j.addAnimation(this.e);
        this.j.addAnimation(this.h);
        this.a.addAnimation(this.f);
        this.a.addAnimation(this.g);
        this.j.setAnimationListener(new c(this));
        this.a.setAnimationListener(new d(this));
        this.setImageResource(this.b);
    }

    public final void a(int arg1, int arg2, boolean arg3) {
        this.k = arg1;
        this.l = arg2;
        this.adaptNightMode(arg3);
    }

    public final void adaptNightMode(boolean arg3) {
        this.p = arg3;
        this.m = this.k;
        this.n = this.l;
        this.b(this.o);
        if(this.b == 0) {
            this.setImageDrawable(null);
        }
        else {
            this.setImageDrawable(this.getResources().getDrawable(this.b));
        }
    }

    static boolean a(AnimationImageView arg1) {
        arg1.d = false;
        return false;
    }

    static boolean a(AnimationImageView arg0, boolean arg1) {
        arg0.o = arg1;
        return arg1;
    }

    public final void a() {
        this.d = true;
        this.startAnimation(this.j);
    }

    private void b(boolean arg2) {
        int v0 = arg2 ? this.m : this.n;
        this.b = v0;
        v0 = arg2 ? this.n : this.m;
        this.c = v0;
    }

    static boolean b(AnimationImageView arg1) {
        return arg1.o;
    }

    static boolean c(AnimationImageView arg1) {
        return arg1.d;
    }

    public void clearAnimation() {
        super.clearAnimation();
        this.d = false;
    }

    public boolean isSelected() {
        return this.o;
    }

    public void setOnClickListener(View.OnClickListener arg2) {
        if(arg2 != null) {
            super.setOnClickListener(new e(this, arg2));
        }
    }

    public void setSelected(boolean arg2) {
        if(!this.d) {
            this.o = arg2;
            this.b(arg2);
            this.setImageResource(this.b);
        }
    }
}

